/**
 * Created by wust on 2019-11-27 13:57:02
 * Copyright © 2019 wust. All rights reserved.
 */
package com.wust.smartcity.demo.server.core.api.feign.server;

import cn.hutool.core.collection.CollectionUtil;
import com.alibaba.fastjson.JSONObject;
import com.wust.smartcity.common.annotations.FeignApi;
import com.wust.smartcity.common.dto.WebResponseDto;
import com.wust.smartcity.common.entity.demo.Demo;
import com.wust.smartcity.demo.server.core.dao.DemoMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;

/**
 * @author: wust
 * @date: Created in 2019-11-27 13:57:02
 * @description:
 *
 */
@FeignApi
@RequestMapping("/api/feign/v1/DemoFeignApi")
@RestController
public class DemoFeignApi {
    @Autowired
    private DemoMapper demoMapper;


    @RequestMapping(value = "/select",method= RequestMethod.POST)
    public WebResponseDto select(@RequestBody Demo search) {
        WebResponseDto responseDto = new WebResponseDto();
        List<Demo> list = demoMapper.select(search);
        if(CollectionUtil.isNotEmpty(list)){
            responseDto.setObj(JSONObject.toJSONString(list));
        }
        return  responseDto;
    }


    @RequestMapping(value = "/updateByPrimaryKeySelective",method= RequestMethod.POST)
    public WebResponseDto updateByPrimaryKeySelective(@RequestBody Demo entity) {
        WebResponseDto responseDto = new WebResponseDto();
        demoMapper.updateByPrimaryKeySelective(entity);
        return  responseDto;
    }
}
